package com.example.helloworld;

import java.io.File;

public class DirList {

    public static void main(String[] args) {
        String dir = "/tmp";
        File f1 = new File(dir);
        if (f1.exists() && f1.isDirectory()) {
            System.out.println("Directory listing of " + dir);
            String files[] = f1.list();
            for (int i = 0; i < files.length; i++) {
                System.out.println(files[i]);
                File f2 = new File(dir + "/" + files[i]);
                if (f2.isDirectory()) {
                    System.out.println("   Directory");
                } else {
                    System.out.println("   File");
                }
            }
        }
        else {
            System.out.println(dir + " is not a directory");
        }
    }
}
